/**
* SocialMashup testing
* $Author: Lars Huring
* Version: 0.1
*/

(function(jQuery) {

	var SocialMashup = {
		
		Settings: {
			version: "1.0",
			networks: ["twitter", "flickr"],
			class_prefix: "sm-",
			url: "SocialMashup/index.php",
			max_results: 20,
			onComplete: function() {}
		},
		
		Socialize: function(arr, options, fn)
		{
			
			this.Collection = arr;
			jQuery.extend(this.Settings, options);
						
			var querystring = "?max_results=" + this.Settings.max_results + "&networks=" + this.Settings.networks.join(",");
			var that = this;

			$.each(arr, function(i, item) {
				var q = $(this).text();		
				$.getJSON(that.Settings.url + querystring + "&search=" + escape(q), that.Settings.onComplete);
			});
			
		}
		
	}

	
	/**
	* Return public methods only
	*/
	var publicMethods = {
		
		socialize: function(options)
		{
			return SocialMashup.Socialize(this, options);
		}
		
	}
	
	/**
	* Make methods public
	*/
	jQuery.each(publicMethods, function(i) {
		jQuery.fn[i] = this;
	});
	
	
})(jQuery);